package com.example.controller;


import com.example.common.annotation.OperLog;
import com.example.common.enums.LogType;
import com.example.common.utils.R;
import com.example.system.entity.AppointmentScheduler;
import com.example.system.entity.Doctor;
import com.example.system.service.IAppointmentSchedulerService;
import com.example.system.service.IDoctorService;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王鹤蒲
 * @since 2024-01-22
 */
@Api(tags = "医生信息API",description="提供医生信息相关的 REST API")
@RestController
@RequestMapping("/doctor")
public class DoctorController {

    @Autowired
    private IDoctorService iDoctorService;

    @OperLog(operation = "医生管理",type = LogType.ADD)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/save",method= RequestMethod.POST)
    @ResponseBody
    public R insert(@RequestBody Doctor doctor) {
        return iDoctorService.insert(doctor);
    }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/selectAll",method= RequestMethod.GET)
    @ResponseBody
    public R selectAll(@RequestParam int currentPage,@RequestParam int pageSize,@RequestParam(defaultValue="") String doctorName,@RequestParam(defaultValue = "") String departmentName) {
       return iDoctorService.selectAll(currentPage,pageSize,doctorName,departmentName);
    }

    @OperLog(operation = "医生管理",type = LogType.DELETE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/delete/{id}",method= RequestMethod.DELETE)
    @ResponseBody
    public R deleteById(@PathVariable("id") int id) {
       return iDoctorService.deleteById(id);
    }

    @OperLog(operation = "医生管理",type = LogType.BATCH_DELETE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/deleteBatch",method= RequestMethod.POST)
    @ResponseBody
    public R deleteByIds(@RequestBody int []ids){
      return iDoctorService.deleteByIds(ids);
    }

    @OperLog(operation = "医生管理",type = LogType.UPDATE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/edit",method= RequestMethod.POST)
    @ResponseBody
    public R edit(@RequestBody Doctor doctor) {
      return iDoctorService.edit(doctor);
    }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/findAllDoctorNames",method= RequestMethod.GET)
    @ResponseBody
    public R findAllDoctorNames(){
      return iDoctorService.findAllDoctorNames();
    }


    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/selectDoctorSchedulerInfo",method= RequestMethod.GET)
    @ResponseBody
    public R selectDoctorSchedulerInfo(@RequestParam Integer userId,@RequestParam String currentMonth) {
        return iDoctorService.selectDoctorSchedulerInfo(userId,currentMonth);
    }
}

